package org.popo;

import java.io.IOException;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.Future;

import com.ning.http.client.AsyncHttpClient;
import com.ning.http.client.AsyncHttpClientConfig;
import com.ning.http.client.Response;

public class HttpUtils {
	private AsyncHttpClientConfig.Builder b;
	private AsyncHttpClient client;

	public HttpUtils() {
		b = new AsyncHttpClientConfig.Builder();
		b.setUserAgent("Mozilla/5.0 (Windows NT 6.1; WOW64; rv:14.0) Gecko/20100101 Firefox/14.0.1");
		client = new AsyncHttpClient(b.build());
	}

	public String getHttp(String url) throws IOException, InterruptedException,
			ExecutionException {
		Future<Response> f = client.prepareGet(url).execute();
		Response response = f.get();
		return response.getResponseBody("gbk");
	}
}
